
package org.sunspotworld.demo;

public class ArticulationMatrix extends DecisionMatrix
{
    private static final int size = 3;
    
    public ArticulationMatrix()
    {
        super(size);
        initializeRoleMatrix();
        initializeAVMatrices();
    }
    
    
    /**
     * Set up the highest/lowest valence/arousal tables that determine the 
     * reactions to changing AV values.
     */
    private void initializeAVMatrices()
    {
        //Articulation is really only affected by arousal, and then it's pretty 
        // straight up -> high arousal = short notes, low arousal = long notes.
        m_lowestValence = new float[][]{{1, 1, 1},
                                        {1, 1, 1},
                                        {1, 1, 1}};
        m_highestValence = new float[][]{{1, 1, 1},
                                         {1, 1, 1},
                                         {1, 1, 1}};
        m_lowestArousal = new float[][]{{1, 50, 100},
                                        {1, 50, 100},
                                        {1, 50, 100}};
        m_highestArousal = new float[][]{{100, 50, 1},
                                         {100, 50, 1},
                                         {100, 50, 1}};
    }
    
    
    /**
     * Set up the starting role probabilities table that determines what notes
     * the mote prefers, depending on role.
     */
    private void initializeRoleMatrix()
    {
        if(SunSpotAudio.m_role == SunSpotAudio.role_harmony)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 2)
                    {
                        //Favor medium-long notes
                        m_roleMatrix[i][j] = 12;
                    }
                    else if(j == 1)
                    {
                        m_roleMatrix[i][j] = 12;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }
        }
        else if(SunSpotAudio.m_role == SunSpotAudio.role_bass)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 2)
                    {
                        //Favor long notes
                        m_roleMatrix[i][j] = 20;
                    }
                    else if(j == 1)
                    {
                        m_roleMatrix[i][j] = 10;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }
        }
        else if(SunSpotAudio.m_role == SunSpotAudio.role_percussion)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 0)
                    {
                        //Favor short notes
                        m_roleMatrix[i][j] = 20;
                    }
                    else if(j == 1)
                    {
                        m_roleMatrix[i][j] = 4;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }
        }
        else //if(SunSpotAudio.m_role == SunSpotAudio.role_melody)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 1)
                    {
                        //Favor medium notes
                        m_roleMatrix[i][j] = 12;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }
        }
    }
}
